/*
 *  Copyright (C) 2010 Glauco
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.common;

import java.io.Serializable;
import java.util.List;
import org.balisunrise.annotation.PanelType;
import org.balisunrise.common.listeners.EntityPanelListener;

/**
 * Painel de edição dos atributos de uma entidade.
 *
 * @author Glauco
 * @param <T> PanelField tipo de dado que representa os atributos da entidade.
 * @param <V> Representação visual do EntityPanel.
 */
public interface EntityPanel<V> extends Layoutable<V> {

    /**
     * Retorna a entidade.
     */
    public Serializable getEntity();

    /**
     * Atribui a entidade.
     *
     * @param entity
     */
    public void setEntity(Serializable entity);

    /**
     * Retorna o Tipo de painel.
     *
     * @see org.balisunrise.annotation.PanelType
     */
    public PanelType getType();

    /**
     * Retorna os EntityPannel associados.<br>
     * Os associados são utilizados apenas quando o tipo de painel não
     * for SINGLE;
     *
     * @see org.balisunrise.annotation.PanelType
     */
    public List<EntityPanel<V>> getAssociatedPanels();

    /**
     * Retorna se os valores da entidade são válidos.
     */
    public boolean isEntityValid();

    /**
     * Realiza o Vínculo entre os componentes visuais e os atributos da entidade.
     */
    public void bind();

    /**
     * Desfaz o Vínculo entre os componentes visuais e os atributos da entidade.
     */
    public void unBind();

    /**
     * Atribui o BindingGroup utilizado para fazer o bind.
     * @param bindingGroup
     */
    public void setBindingGroup(BindingGroup bindingGroup);

    /**
     * Adiciona um listener.
     *
     * @param listener the listener to be added.
     */
    public void addEntityPanelListener(EntityPanelListener listener);

    /**
     * Remove um listener.
     *
     * @param listener the listener to be removed.
     * @return true if the listener was removed, false if the listener was not
     * included.
     */
    public boolean removeEntityPanelListener(EntityPanelListener listener);

    /**
     * Retorna um array com os listeners.
     *
     * @return
     */
    public EntityPanelListener[] getEntityPanelListeners();
}